//<SCRIPT LANGUAGE=javascript>
function checkVIN(VIN){
	VIN = trim(VIN);
	if( VIN.length == 9 )return true;
	if( VIN.length != 17 && VIN.length != 0 )return false;
var aWieghts = new Array(8,7,6,5,4,3,2,10,0,9,8,7,6,5,4,3,2);
var oWeights = initWeights()
var aVIN = VIN.toUpperCase().match(/\S/g),sum=0;
	if( !aVIN )return true;
var x = VIN.charAt(8).toUpperCase();
	for( var i=0; i < aVIN.length; i++ )
		sum += oWeights[aVIN[i]]*aWieghts[i];
	sum = sum % 11;
	return sum==10?x=="X":x==sum;
//Locals
	function initWeights(){
		var oWeights = {};
		oWeights.A = 1;
		oWeights.B = 2;
		oWeights.C = 3;
		oWeights.D = 4;
		oWeights.E = 5;
		oWeights.F = 6;
		oWeights.G = 7;
		oWeights.H = 8;
		oWeights.J = 1;
		oWeights.K = 2;
		oWeights.L = 3;
		oWeights.M = 4;
		oWeights.N = 5;
		oWeights.P = 7;
		oWeights.R = 9;
		oWeights.S = 2;
		oWeights.T = 3;
		oWeights.U = 4;
		oWeights.V = 5;
		oWeights.W = 6;
		oWeights.X = 7;
		oWeights.Y = 8;
		oWeights.Z = 9;
		oWeights['0'] = 0;
		oWeights['1'] = 1;
		oWeights['2'] = 2;
		oWeights['3'] = 3;
		oWeights['4'] = 4;
		oWeights['5'] = 5;
		oWeights['6'] = 6;
		oWeights['7'] = 7;
		oWeights['8'] = 8;
		oWeights['9'] = 9;
		return oWeights;
	}
}
